package material.observer;

import java.util.Observable;

/**
 * 构造一天天气的主题 继承Observable类
 */
public class WeatherDataInner extends Observable {
    private float tempature;
    private float humidity;
    private float pressure;

    public WeatherDataInner() {//与我们自定义的主题相比，我们的构造器已经不需要为了记住观察者而建立数据结构了
    }

    /**
     *
     */
    public void measurementsChanged() {
        setChanged();//在调用notifyObservers方法之前需要先调用setChanged方法来指定状态已经改变
        notifyObservers();//我们没有调用notifyObservers方法来传递对象，这表示我们采用的做法是"拉"

    }

    public void setMeasurements(float tempature, float humidity, float pressure) {
        this.tempature = tempature;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }

    public float getTempature() {
        return tempature;
    }

    public void setTempature(float tempature) {
        this.tempature = tempature;
    }

    public float getHumidity() {
        return humidity;
    }

    public void setHumidity(float humidity) {
        this.humidity = humidity;
    }

    public float getPressure() {
        return pressure;
    }

    public void setPressure(float pressure) {
        this.pressure = pressure;
    }
}
